整理常用的中英文预训练词向量(Pretrained Word Vectors) 您所在的位置:网站首页 judyjudyjudy i中文词 整理常用的中英文预训练词向量(Pretrained Word Vectors)

整理常用的中英文预训练词向量(Pretrained Word Vectors)

#整理常用的中英文预训练词向量(Pretrained Word Vectors)| 来源: 网络整理| 查看: 265

文章目录 引言腾讯中文词汇/短语向量(Tencent AI Lab Embedding Corpus for Chinese Words and Phrases)使用方法 中文词向量语料库 by 北京师范大学&人民大学Stanford GloVe Embeddings 英文词向量fastText word vectors使用方法 词向量训练工具包Reference

引言

NLP用向量表示单词,这些向量捕获有关语言的隐藏信息,例如单词类比或语义。它还用于提高文本分类器的性能,可以广泛应用于许多下游文本处理任务。

本文整理一下常用的中、英文预训练词向量的链接,无须自己训练,下载即可使用。

腾讯中文词汇/短语向量(Tencent AI Lab Embedding Corpus for Chinese Words and Phrases)

官网:https://ai.tencent.com/ailab/nlp/zh/embedding.html 下载页面:https://ai.tencent.com/ailab/nlp/zh/download.html

2021年12月24日发布版本v0.2.0,提供四个版本下载,词汇规模有200万和1200万两种,词向量维度有100和200维两种,大家可以按需求下载。 在这里插入图片描述

数据规模:1200 万个中文词汇、短语数据维度:提供100维、200维词向量数据来源:包含从新闻、网页和小说中收集的大规模文本数据优势:主要在于覆盖率、新鲜度和准确性。包含大量的领域词汇或俚语,如“喀拉喀什面河”、“皇帝菜”、“不念僧佛面”、“冰火两重天”、“煮酒论”英雄”,大多数现有的嵌入语料库都没有涵盖。还有一些近期出现或流行的新鲜词,如“冠病毒”、“元宇宙”、“了不起的新儿”、“流金岁月”、“凡尔赛文学”、“yyds”等。训练方式:Directional Skip-Gram1 使用方法 from gensim.models import KeyedVectors wv_from_text = KeyedVectors.load_word2vec_format(file, binary=False) 中文词向量语料库 by 北京师范大学&人民大学

https://github.com/Embedding/Chinese-Word-Vectors

项目提供超过100种中文词向量,下载后即可用于下游任务。2

此外,项目还提供了中文词类比任务数据集CA8和配套的评测工具,以便对中文词向量进行评估。

数据来源&规模:百度百科(vocab 5422K)、维基百科(vocab 2129K)、人民日报 1947-2017(vocab 1664K)、金融新闻(vocab 2785K)、知乎(vocab 1117K)、微博(vocab 850K)、文学(vocab 702K)、综合(vocab 10653K)、古汉语(vocab 21.8K)等数据维度:300维词向量数据优势:包括不同的表示方式(稠密和稀疏)、不同的上下文特征(词、N元组、字等等)、以及不同的训练语料。训练方式:ngram2vec Stanford GloVe Embeddings 英文词向量

https://nlp.stanford.edu/projects/glove/

GloVe 是一种用于获取单词向量表示的无监督学习算法。对来自语料库的聚合全局词-词共现统计进行训练,得到的表示展示了词向量空间的线性子结构。3

根据数据来源不同,GloVe 英文词向量分为以下几种:

Wikipedia 2014 + Gigaword 5 (6B tokens, 400K vocab, uncased, 50d, 100d, 200d, & 300d vectors, 822 MB download): glove.6B.zipCommon Crawl (42B tokens, 1.9M vocab, uncased, 300d vectors, 1.75 GB download): glove.42B.300d.zipCommon Crawl (840B tokens, 2.2M vocab, cased, 300d vectors, 2.03 GB download): glove.840B.300d.zipTwitter (2B tweets, 27B tokens, 1.2M vocab, uncased, 25d, 50d, 100d, & 200d vectors, 1.42 GB download): glove.twitter.27B.zip fastText word vectors

英文预训练的词向量:https://fasttext.cc/docs/en/english-vectors.html 157 种语言预训练的词向量:https://fasttext.cc/docs/en/crawl-vectors.html

fastText 是一个用于高效学习单词表示和句子分类的库,并提供了预训练的词向量。4

fastText 词表示的关键特性之一是:它能够为任何单词生成向量,甚至是虚构的单词。事实上,fastText 词向量是由其中包含的字符子串向量构建的。这允许为拼写错误的单词或单词连接构建向量。

英文预训练词向量,根据不同规模和语料库,分为以下四种:

wiki-news-300d-1M.vec.zip: 1 million word vectors trained on Wikipedia 2017, UMBC webbase corpus and statmt.org news dataset (16B tokens).wiki-news-300d-1M-subword.vec.zip: 1 million word vectors trained with subword infomation on Wikipedia 2017, UMBC webbase corpus and statmt.org news dataset (16B tokens).crawl-300d-2M.vec.zip: 2 million word vectors trained on Common Crawl (600B tokens).crawl-300d-2M-subword.zip: 2 million word vectors trained with subword information on Common Crawl (600B tokens). 使用方法 import io def load_vectors(fname): fin = io.open(fname, 'r', encoding='utf-8', newline='\n', errors='ignore') n, d = map(int, fin.readline().split()) data = {} for line in fin: tokens = line.rstrip().split(' ') data[tokens[0]] = map(float, tokens[1:]) return data 词向量训练工具包 ngram2vec:https://github.com/zhezhaoa/ngram2vec/word2vec:https://github.com/svn2github/word2vecfasttext:https://github.com/facebookresearch/fastText Reference

Yan Song, Shuming Shi, Jing Li, and Haisong Zhang. Directional Skip-Gram: Explicitly Distinguishing Left and Right Context for Word Embeddings. NAACL 2018 (Short Paper). ↩︎

Shen Li, Zhe Zhao, Renfen Hu, Wensi Li, Tao Liu, Xiaoyong Du, Analogical Reasoning on Chinese Morphological and Semantic Relations, ACL 2018. ↩︎

Jeffrey Pennington, Richard Socher, and Christopher D. Manning. 2014. GloVe: Global Vectors for Word Representation. ↩︎

Mikolov T , Grave E , Bojanowski P , et al. Advances in Pre-Training Distributed Word Representations[J]. 2017. ↩︎



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有